package com.econ.powercloud.ems.service.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.econ.powercloud.ems.dal.entity.EmsCombination;
import com.econ.powercloud.ems.dal.mapper.EmsCombinationMapper;
import com.mysql.cj.util.StringUtils;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author : zjf
 * @Description : emsCombination的DAO层
 * @Date : 2022/4/18 14:18
 * @Modified by : zjf
 */
@Repository
public class EmsCombinationDAO extends ServiceImpl<EmsCombinationMapper, EmsCombination> {


    /**
     * 通过储能站与类型获取已保存的组合集合
     */
    public List<EmsCombination> selectListByTypeAndStationId(Integer type, String stationId){
        LambdaQueryWrapper<EmsCombination> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(!StringUtils.isNullOrEmpty(stationId), EmsCombination::getEnergyStationId, stationId);
        lambdaQueryWrapper.eq(type != null, EmsCombination::getType,type);
        return this.baseMapper.selectList(lambdaQueryWrapper);
    }



}
